//
//  CaiPuRenQiTableViewCell.m
//  KCZ_B段项目
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "CaiPuRenQiTableViewCell.h"
#import "FitHeader.h"
#import <UIImageView+WebCache.h>
#import "FontSizeSingleTon.h"
#define Font [[FontSizeSingleTon shareFontSize]array]
@implementation CaiPuRenQiTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createCell];
    }
    return self;
}

-(void)createCell
{
    _backImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_backImageView];
    
    _titleLable = [[UILabel alloc]init];
    _titleLable.font = [UIFont systemFontOfSize:[Font[0]integerValue]];
    _titleLable.textAlignment = 1;
    _titleLable.textColor = [UIColor whiteColor];
    [_backImageView addSubview:_titleLable];
    
    _tagImageView = [[UIImageView alloc]init];
    _tagImageView.contentMode = UIViewContentModeScaleToFill;
    _tagImageView.image = [UIImage imageNamed:@"iconfont-taglefttxt"];
    [self.contentView addSubview:_tagImageView];
    
    _tagLable = [[UILabel alloc]init];
    _tagLable.font = [UIFont systemFontOfSize:[Font[2]integerValue]];
    [self.contentView addSubview:_tagLable];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _backImageView.frame = CGRectMake(10 * wt, 10 * ht, self.contentView.frame.size.width - 20 * wt, 150 * ht);
    _titleLable.frame = CGRectMake(200 * wt, 100 * ht, 155 * wt, 50 * ht);
    _tagImageView.frame = CGRectMake(_backImageView.frame.origin.x, _backImageView.frame.origin.y + _backImageView.frame.size.height + 5 * ht, 15 * wt, 15 * ht);
    _tagLable.frame = CGRectMake(_tagImageView.frame.origin.x + _tagImageView.frame.size.width + 10 * wt, _tagImageView.frame.origin.y, 330 * wt, _tagImageView.frame.size.height);

    _titleLable.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:0.8];
    
}
-(void)setModel:(ZJHRenQiModel *)model
{
    [_backImageView sd_setImageWithURL:[NSURL URLWithString:model.Cover]];
    _titleLable.text = model.Title;
    NSString *tagString = @" ";
    NSArray *array = [NSArray arrayWithArray:model.Tags];
    for (NSDictionary *dic in array) {
        NSString *name = [dic objectForKey:@"Name"];
        tagString = [tagString stringByAppendingFormat:@"%@ ", name];
    }
    _tagLable.text = tagString;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
